<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 
        onfocus 获取焦点时触发
        onblur  失去焦点时触发
        
        onchange  在改变元素内容并且失去焦点时触发
        oninput  在改变元素内容时触发

     -->
    <input type="text" class="inp">
    <input type="text" class="inp1">
    <input type="text" class="inp2">
    <input type="text" class="inp3">
    <script>
        document.querySelector('.inp').onfocus = function(){
            console.log('获取焦点时触发')
        }
        document.querySelector('.inp1').onblur = function(){
            console.log('失去焦点时触发')
        }
        document.querySelector('.inp2').onchange = function(){
            console.log('改变内容并且失去焦点')
        }
        document.querySelector('.inp3').oninput = function(){
            console.log('改变内容时触发')
        }
        
    </script>
</body>
</html>